﻿package org.openChart.display 
{
	import flash.display.InterpolationMethod;
	import org.openChart.meta.BaseChart;
	import org.openChart.util.Rectangle;
	
	/**
	 * The base class of display chart.
	 * 
	 * @author Chongyuan
	 */
	public class DisplayChart extends DisplayBaseObject implements DisplayInterface
	{
		// The chart type
		private var chartType_:String;
		// How to show this chart.
		private var displayType_:String = FULL_CHART;
		private var parent_:DisplayScreen;
		private var groupSet_:DisplayGroupSet;	
		private var left_:Number;
		private var right_:Number;
		private var top_:Number;
		private var bottom_:Number;
		
		// Only show the elements of this chart.
		public static const ELEMENT_ONLY:String = "element-only";
		// Show the elements and coordinate of this chart.
		public static const FULL_CHART:String = "full-chart";
		// Only show the elements of chart as default, but when
		// the mouse is moving over the chart, show the elements and cooridnate.
		public static const SELECT_FULL:String = "select-full";
		// Never show this chart any more.
		public static const NOT_SHOW:String = "not-show";
		
		public function DisplayChart( chart:BaseChart, parent:DisplayScreen ) 
		{
			this.parent_ = parent;
			this.chartType_ = chart.chartType;
			super(chart);
		}
		
		/**
		 * Override the initial function.
		 */
		public override function initialize():void
		{
			super.initialize();
			this.chartType_ = chart.chartType;
			groupSet_ = new DisplayGroupSet(chart.groupSet, this);
			groupSet_.initialize();	
		}
		
		public override function resize(rectangle:Rectangle):void
		{
			this.left = rectangle.left;
			this.right = rectangle.right;
			this.top = rectangle.top;
			this.bottom = rectangle.bottom;
			groupSet_.resize(rectangle);
			super.resize(rectangle);
		}
		
		public function get chartType():String
		{
			return this.chartType_;
		}
		
		public function set displayType( displayType_:String ):void
		{
			this.displayType_ = displayType_;
		}
		
		public function get displayType():String
		{
			return this.displayType_;
		}
		
		public function get parent():DisplayScreen
		{
			return this.parent_;
		}
		
		public function get chart():BaseChart
		{
			return dataModel as BaseChart;
		}
		
		public function get groupSet():DisplayGroupSet
		{
			return groupSet_;
		}
		
		public function equals( chart:DisplayChart ):Boolean
		{
			return (chartType == chart.chartType) && (displayType_ == chart.displayType);
		}
		
		public function get left():Number
		{
			return left_;
		}
		
		public function set left( left_:Number ):void
		{
			this.left_ = left_;
		}
		
		public function get right():Number
		{
			return right_;
		}
		
		public function set right( right_:Number ):void
		{
			this.right_ = right_;
		}
		
		public function get top():Number
		{
			return this.top_;
		}
		
		public function set top( top_:Number ):void
		{
			this.top_ = top_;
		}
		
		public function get bottom():Number
		{
			return this.bottom_;
		}
		
		public function set bottom( bottom_:Number ):void
		{
			this.bottom_ = bottom_;
		}
		
		public function toString():String
		{
			var str:String = "\n Object:DisplayChart "
			str += "[chartType = " + chartType + "]";
			str += "[desplayType = " + displayType + "]";
			str += "[top = " + top + "] ";
			str += "[left = " + left +"]";
			str += "[right = " + right + "]";
			str += "[bottom= " + bottom + "]";
			str += "[groupSet = " + groupSet + "]";
			return str;
		}
	}
	
}